package com.sskj.gocoin.v.activity;

import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.TextView;

import com.sskj.gocoin.R;
import com.sskj.gocoin.R2;
import com.sskj.gocoin.common.App;
import com.sskj.gocoin.common.widget.ToolBarLayout;
import com.sskj.gocoin.component.DaggerUserDataComponent;
import com.sskj.gocoin.m.bean.UserInfo;
import com.sskj.gocoin.p.activity.SellerApplyPresenter;
import com.sskj.gocoin.utils.ClickUtil;
import com.sskj.gocoin.utils.ToastUtil;
import com.sskj.gocoin.v.base.BaseActivity;
import com.sskj.lib.model.room.UserViewModel;

import javax.inject.Inject;

import butterknife.BindView;

/**
 * 申请商家
 */
public class SellerApplyActivity extends BaseActivity<SellerApplyPresenter> {
//    @BindView(R2.id.iv_back)
//    ImageView ivBack;

    @BindView(R2.id.bt_apply_seller)
    Button btApplySeller;
    @BindView(R2.id.apply_checkbox)
    CheckBox mApplyCheckbox;
    @BindView(R2.id.tv_freeze)
    TextView tvFreeze;
    @BindView(R2.id.tv_content)
    TextView tvContent;
    @BindView(R2.id.toolBar)
    ToolBarLayout toolBar;
    @BindView(R2.id.title)
    TextView title;
    @Inject
    UserViewModel userViewModel;
    //提示语
    private String tip;

    @Override
    protected int getLayoutResId() {
        return R.layout.activity_seller_apply;
    }

    @Override
    public SellerApplyPresenter getPresenter() {
        return new SellerApplyPresenter();
    }

    public static void start(Context context) {
        Intent starter = new Intent(context, SellerApplyActivity.class);
        context.startActivity(starter);
    }

    @Override
    protected void initView() {
        DaggerUserDataComponent.create().inject(this);
        mPresenter.requestUserInfo();
//        ClickUtil.click(ivBack, this::finish);
//        toolBar.setLeftButtonText(App.INSTANCE.getString(R.string.fabimineJavaSellerApplyActivity1));
        toolBar.setLeftButtonOnClickLinster(v -> finish());
        toolBar.setTitle(App.INSTANCE.getString(R.string.strSellerApplyActivity200));
        title.setVisibility(View.GONE);
        ClickUtil.click(btApplySeller, () -> {
            if (mApplyCheckbox.isChecked()) {
                mPresenter.apply();
            } else {
                ToastUtil.getInstance(this).showMessage(TextUtils.isEmpty(tip) ? App.INSTANCE.getString(R.string.strSellerApplyActivity201) : tip);
            }
        });
    }


    public void startFabiPublish() {
        userViewModel.update();
        finish();
//        FabiPublishActivity.start(this);
    }

    public void updateUser(UserInfo data) {
        tvContent.setText(App.INSTANCE.getString(R.string.strSellerApplyActivity202) + data.getUsdt() + App.INSTANCE.getString(R.string.strSellerApplyActivity203));
        tvFreeze.setText(App.INSTANCE.getString(R.string.strSellerApplyActivity204) + data.getUsdt() + App.INSTANCE.getString(R.string.strSellerApplyActivity205));
        tip = App.INSTANCE.getString(R.string.sellerApplyTip) + App.INSTANCE.getString(R.string.strSellerApplyActivity204) + data.getUsdt() + App.INSTANCE.getString(R.string.strSellerApplyActivity205);
    }

}
